<template>
  <div class="app-container">
    <header class="app-header">
      <div class="header-content">
        <div class="logo">
          <img src="@/assets/logo.png" alt="Logo" />
          <span class="logo-title">充电桩管理系统</span>
        </div>
        <nav class="main-nav">
          <el-dropdown>
            <span class="nav-item">查看信息 <el-icon><Van /></el-icon></span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click.native="goTo('/user')">
                  <el-icon><Bicycle /></el-icon> 账单信息
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <el-dropdown>
            <span class="nav-item">充电 <el-icon><Box /></el-icon></span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click.native="goTo('/submitChargeRequest')">
                  <el-icon><Connection /></el-icon> 提交充电请求
                </el-dropdown-item>
                <el-dropdown-item @click.native="goTo('/startCharging')">
                  <el-icon><Odometer /></el-icon> 开始充电
                </el-dropdown-item>
                <el-dropdown-item @click.native="goTo('/stopCharging')">
                  <el-icon><Odometer /></el-icon> 结束充电
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <el-dropdown>
            <span class="nav-item">变更充电信息 <el-icon><ChatRound /></el-icon></span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click.native="goTo('/chMode')">
                  <el-icon><Connection /></el-icon> 变更充电方式
                </el-dropdown-item>
                <el-dropdown-item @click.native="goTo('/modifyAmount')">
                  <el-icon><Odometer /></el-icon> 变更充电电量
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <el-dropdown>
            <span class="nav-item">排队信息 <el-icon><Upload /></el-icon></span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click.native="goTo('/queue')">
                  <el-icon><UploadFilled /></el-icon> 排队信息
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </nav>
        <div class="user-info">
          <span class="username">管理员</span>
          <div class="avatar">
            <el-icon><User /></el-icon>
          </div>
        </div>
      </div>
    </header>
    <main class="main-content">
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" />
        </transition>
      </router-view>
    </main>
  </div>
</template>

<script>
import { User, Van, Bicycle, Box, Connection, Odometer, ChatRound, Upload, UploadFilled } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

export default {
  components: {
    User, Van, Bicycle, Box, Connection, Odometer, ChatRound, Upload, UploadFilled
  },
  setup() {
    const router = useRouter()
    const goTo = (path) => {
      router.push(path)
    }
    return { goTo }
  }
}
</script>

<style>
:root {
  --primary-color: #2b3391;
  --primary-light: #3d47b3;
  --primary-dark: #1a1f5c;
  --gradient-primary: linear-gradient(135deg, #2b3391 0%, #3d47b3 100%);
  --text-light: #ffffff;
  --text-dark: #333333;
  --background-light: #f5f7fa;
  --shadow: 0 4px 6px rgba(43, 51, 145, 0.1);
}

body, html {
  padding: 0;
  margin: 0;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background-color: var(--background-light);
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--gradient-primary);
  box-shadow: var(--shadow);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 12px;
  height: 64px;
}

.logo img {
  height: 32px;
}

.logo-title {
  color: var(--text-light);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
  white-space: nowrap;
  display: inline-block;
}

.main-nav {
  display: flex;
  gap: 24px;
}

.nav-item {
  color: var(--text-light);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.el-dropdown-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.username {
  color: var(--text-light);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.avatar .el-icon {
  font-size: 20px;
  color: var(--text-light);
}

.main-content {
  margin-top: 64px;
  padding: 24px;
  flex: 1;
}

/* 动画效果 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* 通用布局类 */
.flex-float {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex {
  display: flex;
  align-items: center;
}

.page_content {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 24px;
  transition: all 0.3s ease;
}

.page_content:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(43, 51, 145, 0.15);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-content {
    padding: 0 12px;
  }
  
  .main-nav {
    display: none;
  }
  
  .main-content {
    padding: 16px;
  }
}
</style>
